package com.boxfishedu.foreignkey.web;

import com.boxfishedu.foreignkey.entity.Teacher;
import com.boxfishedu.foreignkey.entity.jpa.TeacherJpaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lzx on 16/3/9.
 */
@RestController
@RequestMapping(value = "/teacher")
public class TeacherController {

    @Autowired
    TeacherJpaRepository teacherJpaRepository;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public List<Teacher> getStudentJpql(@RequestParam(required = false) String key) {
        return teacherJpaRepository.findByUsernameContains(key);
    }
}
